

#import <Foundation/Foundation.h>
#import "cocos2d.h"
#import "Box2D.h"
#import "BodyNode.h"

#define kPerfectTakeOffVelocityY 2.0f
const int32 kMaxContactPoints = 128;

struct ContactPoint
{
	b2Fixture*	otherFixture;
	b2Vec2		normal;
	b2Vec2		position;
	b2PointState state;
};

@class Game;
class BikeContactListener;
#pragma wheel
@interface WheelNode :BodyNode{
    GameNode *_game;
	CCSprite *_sprite;
	b2Body *_body;
	float _radius;
	BOOL _awake;
	BOOL _flying;
	BOOL _diving;
	BikeContactListener *_contactListener;
	int _nPerfectSlides;
    
@public
    ContactPoint			contactPoints_[kMaxContactPoints];
	int32					contactPointCount_;
    
}

@property (readonly) BOOL awake;
@property (nonatomic) BOOL diving;

-(void) update:(ccTime)dt;
@end
#pragma mark bike
@interface Bike : BodyNode {
	float _radius;
	BOOL _awake;
	BOOL _flying;
	BOOL _diving;
	BikeContactListener *_contactListener;
	int _nPerfectSlides;
    
    
    
    WheelNode			*wheel1Node_, *wheel2Node_;
    
	b2Body				*wheel1_;
	b2Body				*wheel2_;
    
	b2Body				*axle1_;
	b2Body				*axle2_;
    
	b2PrismaticJoint	*spring1_;
	b2PrismaticJoint	*spring2_;
	b2RevoluteJoint		*motor1_;
	b2RevoluteJoint		*motor2_;
	
	float				baseSpringForce_;
}
@property (readonly) BOOL awake;
@property (nonatomic) BOOL diving;

+ (id) bikeWithGame:(GameNode*)game;
- (id) initWithGame:(GameNode*)game;

- (void) reset;
- (void) sleep;
- (void) wake;
- (void) updatePhysics;
- (void) updateNode;

- (void) landed;
- (void) tookOff;
- (void) hit;

@end


